import { Router,  createRouter, createWebHashHistory} from 'vue-router'
import { setDefaultComponentName } from './utils'

import Layout from '@views/index/main.vue'
import Introduce from '@views/introduce/main.vue'

const routes = [
  { path: '',  redirect: '/login'},
  {
    path: '/login',
    component: () => import(/* webpackChunkName: "login" */ '@views/login/main.vue')
  },
  {
    path: '/',
    component: Layout,
    children: [
      { path: '/introduce', component: Introduce },
      { path: '/svg-icon', component: () => import('@views/demos/svg-icon.vue') },
      { path: '/page-a', component: () => import('@views/cache-views/page-a.vue') },
      { path: '/page-b', component: () => import('@views/cache-views/page-b.vue') },
      { 
        path: '/page-another', 
        component: () => import('@views/cache-views/page-another.vue'),
        meta: {
          keepAlive: false
        }
      }
    ]
  }
]

setDefaultComponentName(routes)

const router = createRouter({
  history: createWebHashHistory(),
  routes
})


router.beforeEach((to,from,next) => {
  console.log()
  next()
})

export default router